package com.dyh.quickdemo.bizDemo.lbdlabel;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.util.Random;

/*
@Author=Joey Wheeler
@Date=2020/12/29 14:57
*/
@Slf4j
public class M {

    @Test
    public void test1(){

        step1:
        log.info("step1");

        step2:
        log.info("step2");

        step3:
        log.info("step3");
    }

    public void un(){
        Random r = new Random();
        int i = r.nextInt(2);
        //if (i<1)
        if (1==1)
            throw new RuntimeException();
    }

    public  static Runnable try3(Runnable r){
        return ()->{
            int c_retry = 0;
            for (int i =0;i<3;i++){
                try {
                    log.info("第{}次执行开始",i);
                    r.run();
                } catch (Exception e) {
                    log.info("第{}次执行失败",i);
                    c_retry++;
                    continue;
                }
                log.info("第{}次执行成功 重试次数{}",i,c_retry);
                break;
            }
        };
    }


    @Test
    public void test3(){
        try3(this::un).run();
    }


    @Test
    public void test2(){

        init:
        for (;;){
            log.info("loop");
            //break init; //直接返回了
           // continue init; //出不来

        }






    }


}
